﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace AudioPlayer.Entity {
	public abstract class BaseEntity {
		#region Variables
		private Hashtable _hashTable;
		#endregion
		#region Constructor
		public BaseEntity() {
			_hashTable = new Hashtable();

		}
		#endregion
		#region Protected
		/// <summary>
		/// Gets the value.
		/// </summary>
		/// <typeparam name="Object">The type of the object.</typeparam>
		/// <param name="name">The name.</param>
		/// <returns></returns>
		protected virtual TValue GetValue<TValue>(string name) {
			if (_hashTable.Contains(name)) {
				return (TValue)_hashTable[name];
			} else {
				return default(TValue);
			}
		}
		/// <summary>
		/// Sets the value.
		/// </summary>
		/// <typeparam name="Object">The type of the Object.</typeparam>
		/// <param name="name">The name.</param>
		/// <param name="data">The data.</param>
		protected virtual void SetValue<TValue>(string name, TValue value) {
			if (_hashTable.Contains(name)) {
				_hashTable.Remove(name);
			}
			_hashTable.Add(name, value);
		}

		/// <summary>
		/// Gets the count of keys.
		/// </summary>
		/// <value>The count.</value>
		protected virtual int Count {
			get {
				return _hashTable.Count;
			}
		}

		/// <summary>
		/// Determines whether this hash has value of specified name.
		/// </summary>
		/// <param name="name">The name.</param>
		protected virtual bool HasValue(string name) {
			if (_hashTable.ContainsKey(name)) {
				return true;
			} else {
				return false;
			}
		}
		#endregion
	}
}
